package leecode

import "sort"

func minimumBoxes(apple []int, capacity []int) int {
	var appleCount int
	for _, count := range apple {
		appleCount += count
	}
	sort.Ints(capacity)
	var (
		result int
		temp   int
	)
	for i := len(capacity) - 1; i >= 0; i-- {
		if temp >= appleCount {
			return result
		}
		temp += capacity[i]
		result++
	}
	return result
}
